package no.ntnu.fp.model;

import java.util.ArrayList;
import java.util.Date;

import query.RoomQuery;
import no.ntnu.fp.swingutil.*;

public class Rooms {
	
	private ArrayList<Room> roomList;
	private CalendarTools ct;
	
	public Rooms() {
		roomList = new ArrayList<Room>();
		ct = new CalendarTools();
		roomList.addAll(RoomQuery.getAllRooms());
	}
	
	public Room[] getAvailableRooms(Date startDate, Date endDate, int size) {
		ArrayList<Room> availableRooms = new ArrayList<Room>();
		availableRooms = query.RoomQuery.getRooms(size, ct.getDateAsLong(startDate), ct.getDateAsLong(endDate));
		
		if ( availableRooms.isEmpty() )
			return null;
		return availableRooms.toArray(new Room[availableRooms.size()]);
	}
	
}
